<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\UserInfo
 *
 * @property integer $id
 * @property integer $user_id
 * @property string $realname
 * @property string $province
 * @property string $city
 * @property string $town
 * @property string $wechat
 * @property string $weibo
 * @property string $maimai
 * @property integer $photo_id
 * @property integer $img_cardfront_id
 * @property integer $img_cardback_id
 * @property integer $img_callcard_id
 * @property string $edu_school
 * @property string $position
 * @property string $user_desc
 * @property string $deleted_at
 * @property \Carbon\Carbon $created_at
 * @property \Carbon\Carbon $updated_at
 * @property-read \App\User $toUser
 * @property-read \App\Images $toPhoto
 * @property-read \App\Images $toCardFront
 * @property-read \App\Images $toCardBack
 * @property-read \App\Images $toCallCard
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereUserId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereRealname($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereProvince($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereCity($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereTown($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereWechat($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereWeibo($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereMaimai($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo wherePhotoId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereImgCardfrontId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereImgCardbackId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereImgCallcardId($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereEduSchool($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo wherePosition($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereUserDesc($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereDeletedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereCreatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereUpdatedAt($value)
 * @property string $role
 * @method static \Illuminate\Database\Query\Builder|\App\UserInfo whereRole($value)
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\Roles[] $user_x_roles
 */
class UserInfo extends Model {

	//定义表名
    protected  $table = 'user_info';
    use SoftDeletes;

    /** 关联用户表 */
    public function toUser(){
        return $this->belongsTo('App\User' ,'user_id');
    }

    /** 用户头像 */
    public function toPhoto(){
        return $this->belongsTo('App\Images','photo_id');
    }

    /** 用户身份证正面 */
    public function toCardFront(){
        return $this->belongsTo('App\Images','img_cardfront_id');
    }

    /** 用户身份证反面 */
    public function toCardBack(){
        return $this->belongsTo('App\Images','img_cardback_id');
    }

    /** 用户名片 */
    public function toCallCard(){
        return $this->belongsTo('App\Images','img_callcard_id');
    }

    public function user_x_roles(){
        return $this->belongsToMany('App\Roles','user_roles','userinfo_id','role_id');
    }


}
